import 'package:flutter_admin/utils/utils.dart';

class BaseTeam {

  String? id;
  String? remark;
  String? sequence;
  String? active;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? teamcode;
  String? teamname;
  String? workshopId;
  String? workshopName;

  BaseTeam({
    this.id,
    this.remark,
    this.sequence,
    this.active,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.teamcode,
    this.teamname,
    this.workshopId,
    this.workshopName,
  });

  BaseTeam copyWith({
    String? id,
    String? remark,
    String? sequence,
    String? active,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
    String? teamcode,
    String? teamname,
    String? workshopId,
  }) {
    return new BaseTeam(
      id: id ?? this.id,
      remark: remark ?? this.remark,
      sequence: sequence ?? this.sequence,
      active: active ?? this.active,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      teamcode: teamcode ?? this.teamcode,
      teamname: teamname ?? this.teamname,
      workshopId: workshopId ?? this.workshopId,
    );
  }

  @override
  String toString() {
    return '''BaseTeam{
      id: id,
      remark: remark,
      sequence: sequence,
      active: active,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
      teamcode: teamcode,
      teamname: teamname,
      workshopId: workshopId,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is BaseTeam &&
          runtimeType == other.runtimeType
          && id== other.id
          && remark== other.remark
          && sequence== other.sequence
          && active== other.active
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
          && teamcode== other.teamcode
          && teamname== other.teamname
          && workshopId== other.workshopId
   );


  factory BaseTeam.fromMap(Map<String, dynamic> map) {
    return new BaseTeam(
      id: map['id']!=false?map['id'].toString() as String?:"",
      remark: map['remark']!=false?map['remark'].toString() as String?:"",
      sequence: map['sequence']!=false?map['sequence'].toString() as String?:"",
      active: map['active']!=false?map['active'].toString() as String?:"",
      createUid: map['create_uid']!=false?map['create_uid'].toString() as String?:"",
      createDate: map['create_date']!=false?map['create_date'].toString() as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'].toString() as String?:"",
      writeDate: map['write_date']!=false?map['write_date'].toString() as String?:"",
      teamcode: map['teamcode']!=false?map['teamcode'].toString() as String?:"",
      teamname: map['teamname']!=false?map['teamname'].toString() as String?:"",
      workshopId: map['workshop_id']!=false?map['workshop_id'][0].toString() as String?:"",
      workshopName: map['workshop_id']!=false?map['workshop_id'][1].toString() as String?:"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'remark': this.remark,
      'sequence': this.sequence,
      'active': this.active,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'teamcode': this.teamcode,
      'teamname': this.teamname,
      'workshopId': this.workshopId,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if(this.workshopId!=null&&this.workshopId!='')['workshop_id','=',int.parse(this.workshopId!)],
    ] as List;
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'remark': this.remark,
      'sequence': this.sequence,
      'active': this.active,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'teamcode': this.teamcode,
      'teamname': this.teamname,
      'workshop_id': this.workshopId,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}